<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>佳口腊味加工店后台</title>

    <script src="js/vue.js"></script>
    <script src="js/axios.js"></script>
    <!-- 引入样式 -->
    <!--    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">-->
    <link rel="stylesheet" href="css/element-ui.css">

    <!-- 引入组件库 -->
    <script src="js/element-ui.js"></script>
    <!--    &lt;!&ndash; 引入样式 &ndash;&gt;-->
    <!--    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">-->
    <!--    &lt;!&ndash; 引入组件库 &ndash;&gt;-->
    <!--    <script src="https://unpkg.com/element-ui/lib/index.js"></script>-->

    <style>
        .el-table .warning-row {
            background: oldlace;
        }

        .el-table .success-row {
            background: #f0f9eb;
        }
    </style>

</head>
<body>
<div id="app">
    <template>
        <div>
            <el-row>
                <el-col :span="19">
                    <h1 style="text-align: center; margin-top: 0px">佳口腊味加工店后台</h1>
                </el-col>
                <el-col :span="5">
                        <el-statistic group-separator="," :precision="2" :value="generalIncome" :title="generalIncomeTitle"></el-statistic>
                </el-col>
            </el-row>
        </div>
    </template>

    <el-row>
        <el-col :span="2">
            <el-button @click="onCreate()">收肉</el-button>
        </el-col>
        <el-col :span="2">
            <el-button @click="onSale()">零售</el-button>
        </el-col>
        <el-col :span="3">
            <el-button @click="onSelectNotPay()">查询未收款订单</el-button>
        </el-col>

        <el-col :span="3">
            <el-button @click="downNotPay()">导出未收款订单</el-button>
        </el-col>

        <el-col :span="13">
            <el-form :model="sizeForm" :rules="rules" ref="ruleForm" label-width="80px" size="max">
                <el-form-item>
                    <el-col :span="4.5">
                        <el-button @click="onSubmitTime('ruleForm')">按日期查询</el-button>
                    </el-col>
                    <el-col :span="4.5">
                        <el-button @click="downTime('ruleForm')">按日期导出</el-button>
                    </el-col>
                    <el-col class="line" :span="0.5">&nbsp;</el-col>
                    <el-col :span="7">
                        <el-form-item prop="startTime">
                            <el-date-picker type="date" placeholder="选择最早日期（包含）" v-model="sizeForm.startTime"
                                            style="width: 100%;"></el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col class="line" :span="0.5">☞</el-col>
                    <el-col :span="7">
                        <el-form-item prop="endTime">
                            <el-date-picker type="date" placeholder="选择最晚日期（不包含）" v-model="sizeForm.endTime"
                                            style="width: 100%;"></el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-form-item>
            </el-form>
        </el-col>

        <el-col :span="1">
            <template v-if="isShow">
                <el-button @click="initTable()" icon="el-icon-refresh-right" circle
                           style="background-color:#E9EEF3;border: none;font-size: 30px"></el-button>
            </template>
            <template v-if="!isShow">
                <el-button icon="el-icon-loading" circle
                           style="background-color:#E9EEF3;border: none;font-size: 30px"></el-button>
            </template>
        </el-col>
    </el-row>
    <!--表格内容-->
    <el-table
            :header-cell-style="{background:'#eef1f6',color:'#606266'}"
            :data="tableData"
            style="width: 100%"
            :summary-method="getSummaries"
            show-summary
            height="450"
            :row-class-name="tableRowClassName">
        <el-table-column
                prop="userName"
                width="100"
                label="名字"
                align="center">
        </el-table-column>
        <el-table-column
                prop="number"
                width="120"
                label="电话"
                align="center">
        </el-table-column>
        <el-table-column
                prop="productType"
                label="类型"
                align="center">
        </el-table-column>
        <el-table-column
                prop="price"
                label="单价"
                align="center">
        </el-table-column>
        <el-table-column
                prop="weight"
                label="重量/斤"
                align="center">
        </el-table-column>
        <el-table-column
                prop="receivable"
                label="应收"
                align="center">
        </el-table-column>
        <el-table-column
                prop="netReceipts"
                label="实收"
                align="center">
        </el-table-column>
        <el-table-column
                prop="details"
                label="备注"
                align="center">
        </el-table-column>
        <el-table-column
                prop="createTime"
                width="160"
                label="创建时间"
                align="center">
        </el-table-column>
        <el-table-column
                prop="time"
                width="160"
                label="收到款时间"
                align="center">
        </el-table-column>
        <el-table-column label="操作" align="center">

            <template slot-scope="scope">
                <el-row>
                    <el-button type="primary" size="mini" @click="onEdit(scope.row)">编辑</el-button>
                </el-row>
                <el-row>
                    <el-button type="danger" size="mini" @click="onDelete(scope.row)">删除</el-button>
                </el-row>
            </template>

        </el-table-column>
    </el-table>

    <!--分页-->
    <el-row>
        <el-pagination
                :page-sizes="[10000, 1000, 100, 50]"
                :current-page.sync="page.currentPage"
                :page-size="page.pageSize"
                :total="page.totalCount"
                @current-change="initTable()"
                @size-change="handleSizeChange"
                layout="total, sizes, prev, pager, next, jumper"
        >
        </el-pagination>
    </el-row>

    <!-- 添加 -->
    <el-dialog  :title="dialogTitle" :visible.sync="dialogFormVisibleCreate" width="400px" top="5vh" center>
        <div  class="info">
            <el-form  :model="formCreate" ref="FormCreate" :rules="rules">
                <!-- 类型 -->
                <el-row>
                    <el-form-item label="加工类型" prop="productType">
                        <el-radio-group v-model="formCreate.productType">
                            <el-radio label="腊肠"></el-radio>
                            <el-radio label="腊肉"></el-radio>
                            <el-radio label="烘干"></el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-row>


                <el-row>
                    <el-form-item prop="userName" label="姓 名：" label-width="5em">
                        <el-input v-model="formCreate.userName" placeholder="请输入客户姓名" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>

                <!-- 重量 -->
                <el-row>
                    <el-form-item prop="weight" label="重 量：" label-width="5em">
                        <el-input v-model="formCreate.weight" placeholder="请输入重量" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>

                <el-row>
                    <el-form-item prop="number" label="电 话：" label-width="5em">
                        <el-input v-model="formCreate.number" placeholder="电话"></el-input>
                    </el-form-item>
                </el-row>

                <el-row>
                    <el-form-item prop="details" label="备 注：" label-width="5em">
                        <el-input v-model="formCreate.details" placeholder="备注" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>
            </el-form>
            <span class="dialog-footer">
                <!-- 提交按钮 -->
              <el-button type="primary" @click="onSubmitCreate('FormCreate')" style="width: 100%">添加</el-button>
            </span>
        </div>
    </el-dialog>

    <!-- 零售 -->
    <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisibleSale" width="400px" top="5vh" center>
        <div class="info">
            <el-form :model="formSale" ref="FormSale" :rules="rules">
                <!-- 类型 -->
                <el-row>
                    <el-form-item label="类型： " prop="productType">
                        <el-radio-group v-model="formSale.productType">
                            <el-radio label="腊肠零售"></el-radio>
                            <el-radio label="腊肉零售"></el-radio>
                            <el-radio label="其它"></el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-row>

                <!-- 重量 -->
                <el-row>
                    <el-form-item prop="weight" label="重 量：" label-width="5em">
                        <el-input v-model="formSale.weight" placeholder="请输入重量" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>

                <el-row>
                    <el-form-item prop="price" label="单 价：" label-width="5em">
                        <el-input v-model="formSale.price" placeholder="请输入单价" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>


                <el-row>
                    <el-form-item prop="details" label="备 注：" label-width="5em">
                        <el-input v-model="formSale.details" placeholder="备注" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>
            </el-form>
            <span class="dialog-footer">
                <!-- 提交按钮 -->
              <el-button type="primary" @click="onSubmitSale('FormSale')" style="width: 100%">添加</el-button>
            </span>
        </div>
    </el-dialog>

    <!-- 修改 -->
    <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisible" width="500px" top="5vh" center>
        <div class="info">
            <el-form :model="form" ref="Form" :rules="rules">
                <!-- 类型 -->
                <el-row>
                    <el-form-item label="加工类型" prop="productType">
                        <el-radio-group v-model="form.productType">
                            <el-radio label="腊肠"></el-radio>
                            <el-radio label="腊肉"></el-radio>
                            <el-radio label="烘干"></el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-row>

                <!-- 姓名 -->
                <el-row>
                    <el-form-item prop="userName" label="姓 名：" label-width="5em">
                        <el-input v-model="form.userName" placeholder="请输入姓名"></el-input>
                    </el-form-item>
                </el-row>

                <!-- 电话 -->
                <el-row>
                    <el-form-item prop="number" label="电 话：" label-width="5em">
                        <el-input v-model="form.number" placeholder="请输入电话" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>

                <!-- 重量 -->
                <el-row>
                    <el-form-item prop="weight" label="重量：" label-width="5em">
                        <el-input v-model="form.weight" placeholder="请输入重量" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>

                <!--实收-->
                <el-row>
                    <el-form-item label="实收：" label-width="5em">
                        <el-input v-model="form.netReceipts" placeholder="实收" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>

                <el-row>
                    <el-form-item label="备注：" label-width="5em">
                        <el-input v-model="form.details" placeholder="备注" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>
            </el-form>
            <span class="dialog-footer">
                <!-- 提交按钮 -->
              <el-button type="primary" v-on:click="onSubmit('Form')" style="width: 100%">确认提交</el-button>
            </span>
        </div>
    </el-dialog>

    <!-- 零售修改 -->
    <el-dialog :title="dialogTitle" :visible.sync="dialogFormVisibleSaleEdit" width="500px" top="5vh" center>
        <div class="info">
            <el-form :model="formSaleEdit" ref="FormSaleEdit" :rules="rules">
                <!-- 类型 -->
                <el-row>
                    <el-form-item label="类型：" prop="productType">
                        <el-radio-group v-model="formSaleEdit.productType">
                            <el-radio label="腊肠零售"></el-radio>
                            <el-radio label="腊肉零售"></el-radio>
                            <el-radio label="其它"></el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-row>


                <!-- 重量 -->
                <el-row>
                    <el-form-item prop="weight" label="重量：" label-width="5em">
                        <el-input v-model="formSaleEdit.weight" placeholder="请输入重量" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>

                <el-row>
                    <el-form-item prop="price" label="单价：" label-width="5em">
                        <el-input v-model="formSaleEdit.price" placeholder="单价" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>

                <!--实收-->
                <el-row>
                    <el-form-item label="实收：" label-width="5em">
                        <el-input v-model="formSaleEdit.netReceipts" placeholder="实收" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>

                <el-row>
                    <el-form-item label="备注：" label-width="5em">
                        <el-input v-model="formSaleEdit.details" placeholder="备注" autocomplete="off"></el-input>
                    </el-form-item>
                </el-row>
            </el-form>
            <span class="dialog-footer">
                <!-- 提交按钮 -->
              <el-button type="primary" v-on:click="onSubmitSaleEdit('FormSaleEdit')"
                         style="width: 100%">确认提交</el-button>
            </span>
        </div>
    </el-dialog>

</div>
</body>
<script>
    var validatePass = (rule, value, callback) => {
        if (value <= app.sizeForm.startTime) {
            callback(new Error('结束时间应比开始时间晚'));
        } else {
            callback();
        }
    };
    var app = new Vue({
        el: '#app',
        data: {
            isLogin:null,
            startTime:"",
            endTime:"",
            generalIncome:0,
            generalIncomeTitle:"选定时间查询总收款",
            isShow: true, /*true:显示刷新图标，false：显示缓冲图标*/
            tableData: [],
            page: {
                currentPage: 1,
                pageSize: 9999,
                totalCount: null
            },
            dialogFormVisibleCreate: false, //添加的
            dialogFormVisibleSale: false, //
            dialogFormVisibleSaleEdit: false,
            dialogFormVisible: false //编辑的控制表单是否显示
            , dialogTitle: "标题" //表单标题
            , form: { //表单数据
                productId: "",
                productType: "",
                userName: "",
                number: "",
                weight: "",
                netReceipts: "",
                details: ""
            },
            formCreate: { //表单数据
                productType: "" //加工类型
                , weight: ""//重量
                , userName: "" //
                , number: "" //
                , details: "" //描述
            },
            formSale: { //表单数据
                productType: "" //加工类型
                , weight: ""//重量
                , price: ''
                , details: "" //描述
            },
            formSaleEdit: {
                productId: ""
                , productType: "" //加工类型
                , weight: ""//重量
                , price: ''
                , netReceipts: ""
                , details: "" //描述
            },
            sizeForm: {
                startTime: '',
                endTime: '',
            },
            rules: { //校验规则
                productType: [
                    {required: true, message: '请选择加工类型', trigger: 'change'}
                ],
                weight: [
                    {required: true, message: '请输入重量', trigger: 'blur'}
                ],
                userName: [
                    {required: true, message: '请输入客户名', trigger: 'blur'}
                ],
                price: [
                    {required: true, message: '请输入价格', trigger: 'blur'}
                ],
                startTime: [
                    {type: 'date', required: true, message: '请选择开始日期', trigger: 'change'}
                ],
                endTime: [
                    {type: 'date', required: true, message: '请选择结束时间', trigger: 'change'},
                    {validator: validatePass, trigger: 'change'}
                ],
            }
        },

        methods: {
            /*保留两位小数*/
            KeepTwoDecimalPlaces(val) {
                return Number(val).toFixed(2);
            },

            onCreate() {
                this.dialogTitle = "添加信息";
                this.dialogFormVisibleCreate = true;
            },

            onSale() {
                this.dialogTitle = "零售信息";
                this.dialogFormVisibleSale = true;
            },
            /*查询未付款的订单*/
            onSelectNotPay() {
                const objApp = this;
                axios.get('/product/selectNotPay')
                    .then(res => {
                        if (res.data.status === 10000) {
                            this.page.totalCount = res.data.data.total;
                            this.tableData = res.data.data.list
                            /*显示刷新图标*/
                            this.isShow = true;
                        }
                    })

            },
            /*导出未付款的订单*/
            downNotPay() {
                window.open("/product/exportData");
                // axios.get('/product/exportData')
                //     .then(res => {
                //         window.open("/product/exportData");
                //         if (res.data.status === 10000) {
                //
                //             /*显示刷新图标*/
                //             this.isShow = true;
                //         }
                //     })

            },

            //按日期计算总收入
            generalIncomeFun() {
                var objApp=this;
                axios.get('/product/selectGeneralIncomeByCreateTime', {params: objApp.sizeForm})
                    .then(res => {
                        if (res.data.status === 10000) {
                            objApp.generalIncome=res.data.data;
                            objApp.generalIncomeTitle="在"+objApp.startTime.toString()+"☞"+objApp.endTime.toString()+"期间总收款";
                            /*显示刷新图标*/
                            this.isShow = true;
                        }
                    });


            },

            onSubmitTime(formName) {
                const objApp = this;
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        /*把生成的时间串组织成YY-MM-DD的格式*/
                        var startTime = objApp.sizeForm.startTime.toString();
                        var endTime = objApp.sizeForm.endTime.toString();
                        objApp.startTime=objApp.tranTime(startTime);
                        objApp.endTime=objApp.tranTime(endTime);

                        axios.get('/product/selectByCreateTime', {params: objApp.sizeForm})
                            .then(res => {
                                if (res.data.status === 10000) {
                                    this.page.totalCount = res.data.data.total;
                                    this.tableData = res.data.data.list

                                    //触发总收入查询
                                    objApp.generalIncomeFun();
                                    /*显示刷新图标*/
                                    this.isShow = true;
                                }
                            });
                    }
                })
            },
            /*把生成的时间串组织成YY-MM-DD的格式*/
            tranTime(time){
                console.log(time)
                var M = time.substring(4, 7);
                var D = time.substring(8, 10);
                var Y = time.substring(11, 15);

                switch (M) {
                    case "Jan":
                        M = "01";
                        break;
                    case "Feb":
                        M = "02";
                        break;
                    case "Mar":
                        M = "03";
                        break;
                    case "Apr":
                        M = "04";
                        break;
                    case "May":
                        M = "05";
                        break;
                    case "Jun":
                        M = "06";
                        break;
                    case "Jul":
                        M = "07";
                        break;
                    case "Aug":
                        M = "08";
                        break;
                    case "Sep":
                        M = "09";
                        break;
                    case "Oct":
                        M = "10";
                        break;
                    case "Nov":
                        M = "11";
                        break;
                    case "Dec":
                        M = "12";
                        break;
                }
               var formatTime = Y + "-" + M + "-" + D;
                return formatTime;
            },

            downTime(formName) {
                const objApp = this;
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        axios.get('/product/downByCreateTime', {params: objApp.sizeForm})
                            .then(res => {
                                /*把生成的时间串组织成YY-MM-DD的格式*/
                                var startTime = objApp.sizeForm.startTime.toString();
                                var endTime = objApp.sizeForm.endTime.toString();
                                startTime=objApp.tranTime(startTime);
                                endTime=objApp.tranTime(endTime);

                                console.log(startTime + ":" + endTime)
                                window.location = "/product/downByCreateTime?startTime=" + startTime + "&endTime=" + endTime; //跳转
                                // if (res.data.status === 10000) {
                                //     this.page.totalCount = res.data.data.total;
                                //     this.tableData = res.data.data.list
                                //     /*显示刷新图标*/
                                //     this.isShow = true;
                                // }
                            });
                    }
                })
            },

            tableRowClassName({row, rowIndex}) {
                if (rowIndex % 4 === 3) {
                    return 'warning-row';
                } else if (rowIndex % 4 === 1) {
                    return 'success-row';
                }
                return '';
            },

            initTable() {
                /*显示缓冲图标*/
                this.isShow = false;
                axios.get('/product/getPage', {params: this.page})
                    .then(res => {
                        if (res.data.status === 10000) {
                            this.page.totalCount = res.data.data.total;
                            this.tableData = res.data.data.list
                            /*显示刷新图标*/
                            this.isShow = true;
                        }
                    })
            },
            // pageSize改变时
            handleSizeChange(val) {
                console.log(val)
                this.page.pageSize = val;
                this.initTable();
            },
            onDelete: function (row) {
                const objApp = this;
                this.$confirm("确定要删除 [ " + row.userName + " ] 在 [ " + row.createTime + " ] 的订单吗？", '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: "warning"
                }).then(() => {
                    //处理删除操作
                    const params = new URLSearchParams();
                    params.append("productId", row.productId)
                    axios.post("/product/delete", params).then(function (resp) {
                        const json = resp.data;
                        if (json.status == 10000) {
                            //刷新
                            objApp.initTable();
                            //前端弹窗提示
                            objApp.$message({
                                message: '删除成功',
                                type: 'success'
                            });
                        } else {
                            console.error(json);
                        }
                    })
                });
            },
            onEdit: function (row) {
                console.log(row);

                if (row != null) {
                    //点击修改按钮,显示"修改"表单
                    //row代表当前行数据
                    console.log(row.productType);
                    if (row.productType == "腊肠零售" || row.productType == "腊肉零售" || row.productType == "其它") {
                        this.showDialogSale(row);
                    } else {
                        this.showDialog(row);
                    }
                }
            },
            showDialog(data) {
                if (data != null) {
                    this.dialogTitle = "修正 [ " + data.userName + " ] 在 [ " + data.createTime + " ] 的订单";
                    this.form = data;
                    console.log(this.form)
                    this.dialogFormVisible = true;
                }
            },
            showDialogSale(data) {
                if (data != null) {
                    this.dialogTitle = "修正 [ " + data.productType + " ] 在 [ " + data.createTime + " ] 的订单";
                    this.formSaleEdit = data;
                    this.dialogFormVisibleSaleEdit = true;
                }
            },
            onSubmitCreate(FormCreate) {
                const objApp = this;
                this.$refs[FormCreate].validate((valid) => {
                    if (valid) {
                        //表单提交处理
                        //组织参数
                        const params = new URLSearchParams();
                        params.append("productType", objApp.formCreate.productType);
                        params.append("weight", objApp.formCreate.weight);
                        params.append("userName", objApp.formCreate.userName);
                        params.append("number", objApp.formCreate.number);
                        params.append("details", objApp.formCreate.details);
                        //此处请求的url可以时create/也可以是update
                        axios.post("/product/add", params).then(function (resp) {
                            const json = resp.data;
                            if (json.status == 10000) {
                                //前端弹窗提示
                                objApp.$message({
                                    message: "数据处理成功",
                                    type: "success"
                                });
                                //关闭编辑器
                                objApp.dialogFormVisibleCreate = false;
                                //清空表单缓存
                                objApp.formCreate.productType = "";
                                objApp.formCreate.weight = "";
                                objApp.formCreate.userName = "";
                                objApp.formCreate.number = "";
                                objApp.formCreate.details = "";
                                //跳转到当前页,刷新
                                objApp.initTable();
                            } else {
                                console.error(json);
                                //前端弹窗提示
                                objApp.$message.error({
                                    message: json.msg
                                })
                            }
                        })
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            onSubmitSale(FormSale) {
                const objApp = this;
                this.$refs[FormSale].validate((valid) => {
                    if (valid) {
                        //表单提交处理
                        //组织参数
                        const params = new URLSearchParams();
                        params.append("productType", objApp.formSale.productType);
                        params.append("weight", objApp.formSale.weight);
                        params.append("price", objApp.formSale.price);
                        params.append("details", objApp.formSale.details);

                        // console.log(params.get())
                        //此处请求的url可以时create/也可以是update
                        axios.post("/product/sale", params).then(function (resp) {
                            const json = resp.data;
                            if (json.status == 10000) {
                                //前端弹窗提示
                                objApp.$message({
                                    message: "数据处理成功",
                                    type: "success"
                                });
                                //关闭编辑器
                                objApp.dialogFormVisibleSale = false;
                                //清空表单缓存
                                objApp.formSale.productType = "";
                                objApp.formSale.weight = "";
                                objApp.formSale.price = "";
                                objApp.formSale.details = "";
                                //跳转到当前页,刷新
                                objApp.initTable();
                            } else {
                                console.error(json);
                                //前端弹窗提示
                                objApp.$message.error({
                                    message: json.msg
                                })
                            }
                        })
                    } else {
                        console.log('error submit!!');
                        return false;
                    }
                });
            },
            onSubmit: function (form) {
                const objApp = this;
                // const formData = this.form;
                this.$refs[form].validate(function (valid) {
                    if (valid) {
                        //表单提交处理
                        //组织参数
                        const params = new URLSearchParams();
                        params.append("productId", objApp.form.productId);
                        params.append("userName", objApp.form.userName);
                        params.append("number", objApp.form.number);
                        params.append("productType", objApp.form.productType);
                        params.append("weight", objApp.form.weight);
                        params.append("netReceipts", objApp.form.netReceipts * 1); //*1变为数字类型
                        params.append("details", objApp.form.details);
                        //此处请求的url可以时create/也可以是update
                        axios.post("/product/update", params).then(function (resp) {
                            const json = resp.data;
                            if (json.status == 10000) {
                                //前端弹窗提示
                                objApp.$message({
                                    message: "数据处理成功",
                                    type: "success"
                                });
                                //关闭编辑器
                                objApp.dialogFormVisible = false;
                                //跳转到当前页,刷新
                                objApp.initTable();
                            } else {
                                console.error(json);
                                //前端弹窗提示
                                objApp.$message.error({
                                    message: json.msg
                                })
                            }
                        })

                    }
                });
            },
            /*修改零售订单*/
            onSubmitSaleEdit: function (FormSaleEdit) {
                const objApp = this;
                // const formData = this.form;
                this.$refs[FormSaleEdit].validate(function (valid) {
                    if (valid) {
                        //表单提交处理
                        //组织参数
                        const params = new URLSearchParams();
                        params.append("productId", objApp.formSaleEdit.productId);
                        params.append("productType", objApp.formSaleEdit.productType);
                        params.append("weight", objApp.formSaleEdit.weight);
                        params.append("price", objApp.formSaleEdit.price);
                        params.append("netReceipts", objApp.formSaleEdit.netReceipts * 1); //*1变为数字类型
                        params.append("details", objApp.formSaleEdit.details);
                        //此处请求的url可以时create/也可以是update
                        axios.post("/product/saleEdit", params).then(function (resp) {
                            const json = resp.data;
                            if (json.status == 10000) {
                                //前端弹窗提示
                                objApp.$message({
                                    message: "数据处理成功",
                                    type: "success"
                                });
                                //关闭编辑器
                                objApp.dialogFormVisibleSaleEdit = false;
                                //跳转到当前页,刷新
                                objApp.initTable();
                            } else {
                                console.error(json);
                                //前端弹窗提示
                                objApp.$message.error({
                                    message: json.msg
                                })
                            }
                        })

                    }
                });
            },
            /*合计函数*/
            getSummaries(param) {
                const {columns, data} = param;
                const sums = [];
                columns.forEach((column, index) => {
                    if (index === 0) {
                        sums[index] = '总价';
                        return;
                    }
                    if (index == 1 || index == 2 || index == 3 || index == 7 || index == 8 || index == 9 || index == 10) {
                        sums[index] = '';
                        return;
                    }
                    const values = data.map(item => Number(item[column.property]));
                    if (!values.every(value => isNaN(value))) {
                        sums[index] = values.reduce((prev, curr) => {
                            const value = Number(curr);
                            if (!isNaN(value)) {
                                return prev + curr;
                            } else {
                                return prev;
                            }
                        }, 0);
                        sums[index] = sums[index].toFixed(2); //保留2位小数
                        if (index == 4) {
                            sums[index] += ' 斤';
                        } else {
                            sums[index] += ' 元';
                        }
                    } else {
                        sums[index] = 'N/A';
                    }
                });

                return sums;
            },

        },
        mounted() {
            // this.isLogin=localStorage.getItem("account");
            // console.log(this.isLogin);
            if (sessionStorage.getItem("account")==null){
                //未登录
                window.location="login.html";
            }
            this.initTable();
            this.dialogFormVisible = false;
        }
    })
</script>
</html>